package DSENS;

/**
 *
 * @author teeteto
 */
import java.util.ArrayList;

public class RandomNetworkManager extends NetworkManager{


    double conThreshold ; //serve a definire il numero di connessioni
    int maxDistance; //serve ad indicare la distanza massima tra due nodi
    int minDistance; //serve ad indicare la distanza minima tra due nodi

    RandomNetworkManager(ArrayList<Node> net, double cT){
        super(net);
        this.conThreshold = cT;
        this.maxDistance = 10;
        this.minDistance = 1;
    }

    RandomNetworkManager(ArrayList<Node> net, double cT, int maxD, int minD){
        super(net);
        this.conThreshold = cT;
        this.maxDistance = maxD;
        this.minDistance = minD;
    }
/**
 * Generate a network having random links among nodes.
 * A link between two nodes is created if the random nuber generated is grater
 * than a given "connectio" threshold (cT).
 */
    public void initNetworks(){
        ArrayList<Neighbour> nb;
        for(int i=0; i<network.size(); i++) {
            nb = new ArrayList<Neighbour>(1);
            for (int j=0;j<network.size();j++){
                if(i!=j && this.conThreshold > Math.random()) nb.add(new Neighbour(1,j));
            }
            network.get(i).setNeighborood(nb);
        }
   }

}
